import request from '../utils/request'

// 登录
export const login = (username, password) => request({
  url: 'login',
  method: 'POST',
  data: {
    username,
    password
  }
})

// 添加用户的信息
export const addUsers = ({ username, password, email, mobile }) => request({
  url: 'users',
  method: 'POST',
  data: {
    username,
    password,
    email,
    mobile
  }
})

// 设置用户的信息
export const setUsers = ({ id, email, mobile }) => request({
  url: `users/${id}`,
  method: 'PUT',
  data: {
    email,
    mobile
  }
})
// 查询用户的信息
export const getUsers = (id) => request({
  url: `users/${id}`,
  method: 'GET'
})

// 根据id删除用户
export const deleteUsers = (id) => request({
  url: `users/${id}`,
  method: 'DELETE'
})
// 分配角色
export const setPowerUsers = ({ id, role }) => request({
  url: `users/${id}/${role}`,
  method: 'PUT'
})
